package com.ldp.designpatterns.study.interpreter.abstractExpression;

/**
 * @ClassName AddExpression TODO:加法表达式类
 * @Description TODO 解释器模式——解释器模式适用于需要解释和处理特定语言或表达式的情况，它通过将语句表示为抽象语法树并提供解释器来执行解释
 * @Author lindipei
 * @Date 2023/10/18 16:20
 */
public class AddExpression implements Expression {
    private Expression leftOperand;
    private Expression rightOperand;

    public AddExpression(Expression leftOperand, Expression rightOperand) {
        this.leftOperand = leftOperand;
        this.rightOperand = rightOperand;
    }

    @Override
    public int interpret() {
        return leftOperand.interpret() + rightOperand.interpret();
    }
}
